#include <my_header.h>
/*Usage:02_creatfile_w  */
int main(int argc, char *argv[]){

    char *file_name = "1.txt";
    char *context = "hello world!";
    //设置int类型用来表示要传入pipe中那个参数的长度
    int file_len = strlen(file_name);
    int context_len = strlen(context);
    int pipe_fd = open("1.pipe",O_WRONLY);
    //先传入文件名字的长度
    ssize_t ret = write(pipe_fd, &file_len, sizeof(int));
    ERROR_CHECK(ret , -1, "write file_name_len error");
    //传入文件的名字
    ssize_t sret = write(pipe_fd, file_name, file_len);
    ERROR_CHECK(sret, -1, "write file_name error");


    //先传入文件名字的长度
    ssize_t ret1 = write(pipe_fd, &context_len, sizeof(int));
    ERROR_CHECK(ret1, -1, "write context_len error");
    //传入文件的名字
    ssize_t sret1 = write(pipe_fd, context, context_len);
    ERROR_CHECK(sret1, -1, "write context error");


    close(pipe_fd);
    return 0;
}


